package com.atguigu.gulimail.product.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration                                  //mybatis的配置类
@EnableTransactionManagement                    //开启事务
@MapperScan("com.atguigu.gulimail.product.dao") //开启dao包扫描
public class MybatisConfig {
    //添加分页插件的bean
    @Bean
    public PaginationInterceptor  paginationInterceptor(){
        //创建分页插件的实例对象
        PaginationInterceptor paginationInterceptor =  new PaginationInterceptor();
        //设置请求页面的操作 大于最大页操作，t'rue调到首页  false则继续请求，默认值false
        paginationInterceptor.setOverflow(true);
        //每页最大单页的限制数量，默认为500条， -1表示不受限制
        paginationInterceptor.setLimit(1000);
        //返回分页插件的实例对象
        return paginationInterceptor;
    }
}
